<?php
/**
 * Created by PhpStorm.
 * User: 1
 * Date: 2016-11-28
 * Time: 14:36
 */

namespace app\domain;


use app\src\alibaichuan\service\OpenImRelationsGetService;
use app\src\user\logic\MemberConfigLogic;
use app\src\user\logic\MemberLogic;

class AlibaichuanDomain extends BaseDomain
{
    public function openIMRelations(){
        $uid = $this->_post('uid','',lang("uid_need"));
        $beginDate = $this->_post('begin_date','');
        $now = time()+24*3600;
        //20天之前
        if($now - strtotime($beginDate) > 20*24*3600 ){
            $beginDate = date("Ymd",$now-20*24*3600);
        }

        $endDate = date("Ymd",$now);
        $logic = new MemberConfigLogic();
        $result = $logic->getInfo(['uid'=>$uid]);
        $this->exitWhenError($result);
        $memberCfg = $result['info'];
        $baichuan_uid = $memberCfg['alibaichuan_id'];

        $service = new OpenImRelationsGetService();

        $result = $service->getRelations($baichuan_uid,$beginDate,$endDate);

        $this->returnResult($result);
    }
}